package function.lly;

import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * Created by lxue on 16/5/10.
 */
public class Main {
    public static void main(String[] args) {
        Promise<String> promise = new PromiseImpl<>(new BiConsumer<Consumer<String>, Consumer<Exception>>() {
            @Override
            public void accept(Consumer<String> stringConsumer, Consumer<Exception> exceptionConsumer) {
//                stringConsumer.accept("haha");
                exceptionConsumer.accept(new IllegalArgumentException());
            }
        });
        Promise<Integer> result = promise.onFulfilled(new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                if (s.equals("haha")) {
                    System.out.println("pass");
                    return 1;
                }
                return 0;
            }
        });
    }
}
